package com.sky.controller.admin;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.entity.Orders;
import com.sky.mapper.OrderMapper;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.service.impl.OrderServiceImpl;
import com.sky.vo.OrderDishVO;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminOrderController")
@RequestMapping("/admin/order")
@Slf4j
@Api(tags = "订单接口u")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/conditionSearch")
    @ApiOperation("订单查询接口")
    public Result<PageResult> search(OrdersPageQueryDTO ordersPageQueryDTO){
        PageResult pageResult = orderService.search(ordersPageQueryDTO);
        return Result.success(pageResult);
    }
    @GetMapping("/details/{id}")
    @ApiOperation("订单详情接口")
    public Result<OrderVO> getById(@PathVariable Long id){
        OrderVO orders = orderService.getById(id);
        return Result.success(orders);

    }
    @PutMapping("/rejection")
    @ApiOperation("订单拒绝接口")
    public Result rejection(@RequestBody OrdersRejectionDTO ordersRejectionDTO){
        orderService.rejection(ordersRejectionDTO);
        return Result.success();
    }
    @PutMapping("/confirm")
    @ApiOperation("订单确认接口")
    public Result confirm(@RequestBody OrdersConfirmDTO ordersConfirmDTO){
        orderService.confirm(ordersConfirmDTO);
        return Result.success();
    }
    @PutMapping("/cancel")
    @ApiOperation("订单取消接口")
    public Result cancel(@RequestBody OrdersCancelDTO ordersCancelDTO){
        orderService.cancel(ordersCancelDTO);
        return Result.success();
    }
    @PutMapping("/delivery/{id}")
    @ApiOperation("订单派送接口")
    public Result deliver(@PathVariable Long id){
        orderService.deliver(id);
        return Result.success();
    }
    @PutMapping("/complete/{id}")
    @ApiOperation("订单完成接口")
    public Result complete(@PathVariable Long id){
        orderService.complete(id);
        return Result.success();
    }
    @GetMapping("/statistics")
    @ApiOperation("订单统计接口")
    public Result<OrderStatisticsVO> statistics(){
        OrderStatisticsVO count = orderService.statistics();
        return Result.success(count);
    }
}
